package com.snopy.designPattern.structure.flyweight;

import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;

/**
 * @author snopy
 * @version 1.0.0
 * @classname Forest
 * @description
 * @email 77912204@qq.com
 * @date 2022/11/27 20:52
 */
public class Forest extends JFrame {

    private List<Tree> trees = new ArrayList<>();

    public void plantTree(int x, int y, String name, Color color,String otherTreeData){
        //TreeType type = TreeFactory.getTreeType(name,color,otherTreeData);
        Tree tree = new Tree(x,y,new TreeType(name,color,otherTreeData));
        trees.add(tree);
    }

    @Override
    public void paint(Graphics g) {
        for (Tree tree:trees) {
            tree.draw(g);
        }
    }
}
